'use strict';

const Controller = require('egg').Controller;
const { call } = require("../utils/useCallBack");
class myController extends Controller {
  async index() {
    const { ctx } = this;

    call(2, (e) => {
      console.log(e)
      ctx.body = e
    });

  }
  async getGirls() {
    const { ctx } = this;
    const res = await ctx.service.my.getUser(ctx.query.id);
    ctx.body = res;
  }

  async missYou() {
    const { ctx } = this;
    // 自由传参模式
    ctx.body = 'miss you!' + (ctx.query.name || 'noName');
  }

  // 严格传参模式
  async missMe() {
    const { ctx } = this;
    ctx.body = ctx.params
  }

  // POST 请求
  async learnPost() {
    const { ctx } = this;
    // post的参数
    ctx.body = ctx.request.body
  }

  async getUserList() {
    const { ctx } = this;

    ctx.body = await ctx.service.my.getUserList(1)
  }
}
module.exports = myController;
